package 设计模式.segregation;

public class SegregationNew {
    public static void main(String[] args) {
        A1 a1 = new A1();
        a1.depend1(new B1());
        a1.depend2(new B1());
        a1.depend3(new B1());
    }
}
interface Interface1{
    void operation1();
}
interface Interface2{
    void operation2();
    void operation3();
}
interface Interface3{
    void operation4();
    void operation5();
}

class B1 implements Interface1,Interface2{
    public void operation1(){
        System.out.println("B实现了1");
    }
    public void operation2(){
        System.out.println("B实现了2");
    }
    public void operation3(){
        System.out.println("B实现了3");
    }
}

class D1 implements Interface1,Interface3{
    public void operation1(){
        System.out.println("B实现了1");
    }
    public void operation4(){
        System.out.println("B实现了4");
    }
    public void operation5(){
        System.out.println("B实现了6");
    }
}
//A依赖B使用1、2、3方法
class A1{
    public void depend1(Interface1 i){
        i.operation1();
    }
    public void depend2(Interface2 i){
        i.operation2();
    }
    public void depend3(Interface2 i){
        i.operation3();
    }
}

//C依赖D使用1、4、5方法
class C1{
    public void depend1(Interface1 i){
        i.operation1();
    }
    public void depend2(Interface3 i){
        i.operation4();
    }
    public void depend3(Interface3 i){
        i.operation5();
    }
}